<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
    <input type="text" name="" v-model="newTodo">
    <button @click="addTodo">添加</button>
    <ul>
        <li v-for="(todo,index) in todos" >
            {{todo}}
            <button @click="removeTodo(index)">删除</button>
        </li>
    </ul>
</div>
</body>
<script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data: {
            todos:["vue","django","flask"],
            newTodo:'',
        },
        methods: {
            addTodo: function () {
                //添加到列表中
                this.todos.push(this.newTodo)
                //清空输入框
                this.newTodo = ''
            },
            removeTodo: function (index) {
                this.todos.splice(index,1)
            }
        }
    })
</script>
</html>